package com.qd.common.sys.domain.entity.org;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.cdqidi.util.page.BaseQuery;
import com.cdqidi.valid.group.DefaultGroup;
import com.cdqidi.valid.group.UpdateGroup;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;

/**
 * @author sjk
 * 机构和人员
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class OrgPersonDTO extends BaseQuery {
    @JsonIgnore
    @ExcelIgnore
    private static final String EXCEL_TITLE = "人员和机构关系";
    /**
     * 主键
     */
    @ExcelProperty(value = {EXCEL_TITLE, "关系ID"})
    @NotBlank(message = "部门和人员ID不能为空", groups = {UpdateGroup.class})
    @Size(max = 50, message = "部门和人员ID长度不能超过{max}位", groups = {DefaultGroup.class, UpdateGroup.class})
    private String orgPersonId;
    /**
     * 人员ID
     */
    @ColumnWidth(35)
    @ExcelProperty(value = {EXCEL_TITLE, "*人员ID"})
    @NotBlank(message = "人员ID不能为空", groups = DefaultGroup.class)
    @Size(max = 50, message = "人员ID长度不能超过{max}位", groups = DefaultGroup.class)
    private String personId;
    /**
     * 人员名称
     */
    @ExcelProperty(value = {EXCEL_TITLE, "人员姓名"})
    private String personIdDisplay;
    /**
     * 机构ID
     */
    @ColumnWidth(35)
    @ExcelProperty(value = {EXCEL_TITLE, "*机构ID"})
    @NotBlank(message = "机构ID不能为空", groups = DefaultGroup.class)
    @Size(max = 50, message = "机构ID长度不能超过{max}位", groups = DefaultGroup.class)
    private String orgId;
    /**
     * 机构名称
     */
    @ColumnWidth(35)
    @ExcelProperty(value = {EXCEL_TITLE, "机构名称"})
    private String orgIdDisplay;
    /**
     * 添加时间
     */
    @ExcelProperty(value = {EXCEL_TITLE, "添加时间"})
    private LocalDateTime addTime;
    /**
     * 更新时间
     */
    @ExcelIgnore
    private LocalDateTime updateTime;
    /**
     * 只是查询的时候用作接收参数
     */
    @ExcelIgnore
    private String personName;

    @Override
    public void freeData() {
        this.orgPersonId = null;
        this.addTime = null;
        this.updateTime = null;
        this.personId = null;
        this.orgId = null;
        this.orgIdDisplay = null;
        this.personName = null;
    }
}
